package com.lfd.springboottransaction.controller;

import com.lfd.springboottransaction.pojo.Course;
import com.lfd.springboottransaction.service.CourseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RestController;

/**
 * @项目名： spring-emq
 * @包名： com.lfd.springboottransaction.controller
 * @文件名: CourseCroller
 * @创建者: liufudong@szyh-smart.com
 * @创建时间: 2024/10/3 21:09
 * @描述：
 */
@RestController
@Slf4j
public class CourseController {
    @Autowired
    private CourseService courseService;

    @Transactional
    public void testTransactional() {
        boolean save1 = courseService.save(Course.builder().name("张三44").build());
        log.info("save1======{}", save1);
        int i = 1 / 0;
        boolean save2 = courseService.save(Course.builder().name("张三55").build());
        log.info("save2======{}", save2);
    }

}
